﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace ebay.Dal
{
    public class DBUtility
    {
        public static string GetSrialNumber(DateTime dt, string Code)
        {
            SqlParameter[] p = {
                               new SqlParameter("@SERDATE",SqlDbType.DateTime),
                               new SqlParameter("@SERNO",SqlDbType.VarChar,3),
                               new SqlParameter("@RET_SERIAL",SqlDbType.VarChar,20)
                               };
            p[0].Value = dt;
            p[1].Value = Code;
            p[2].Direction = ParameterDirection.Output;
            try
            {
                SqlHelper.ExecuteNonQuery(SqlHelper.ceterDB_Conn, CommandType.StoredProcedure, "sp_GetSerial", p);
                object val = p[2].Value;
                if (val == DBNull.Value || val == null)
                {
                    return null;
                }
                return val.ToString();

            }
            catch
            {
                return null;
            }
        }
    }
}
